package xj.graph2d.command;

import xj.graph2d.Arrow;
import xj.graph2d.GraphDocument;
import xj.graph2d.GraphEdgeBase;
import xj.graph2d.GraphView;

public class FlipEdgeCommand extends AbstractCommand {

  public FlipEdgeCommand(GraphView view, 
			 GraphDocument doc, 
			 GraphEdgeBase edge) { 
    super(view, doc);
    this.edge = edge;
    graph = doc;
  }

  public void execute() {
    doFlipEdge();
  }

  public void undo() {
    doFlipEdge();
  }

  void doFlipEdge() { 
    if (edge != null && 
	edge.isFlippable()) { 
      graph.flipEdgeOrientation(edge);
      canvas.repaint();
    }
  }

  protected GraphEdgeBase edge;
  protected GraphDocument graph;

}
